#include <iostream>
#include <queue>

using namespace std;

int n, k;
string ch[350];
bool vis[350][350];
const int dir[4][2] = {{-1, 0},
                       {1,  0},
                       {0,  1},
                       {0,  -1}};
int far;

struct Node {
    int x, y, t;

    Node(int xx, int yy, int tt) : x(xx), y(yy), t(tt) {}
};

void bfs() {
    queue<Node> q;
    q.push({2, 2, 0});
    vis[2][2] = true;

    while (!q.empty()) {
        Node now = q.front();
        //开始记录胖子的体重
        far = now.t >= 2 * k ? 1 : now.t >= k ? 3 : 5;

        if (far != 1) {
            q.push({now.x, now.y, now.t + 1});
        }

        for (int i = 0; i < 4; ++i) {
            int mx = now.x + dir[i][0];
            int my = now.y + dir[i][1];

            //越界
            if (mx - far / 2 < 0 || my - far / 2 < 0 || mx + far / 2 >= n || my + far / 2 >= n) {
                continue;
            }
            //是否是已经走过
            if (vis[mx][my]) {
                continue;
            }

            //判断是否在胖子的范围内设有障碍物
            bool flag = false;
            for (int a = mx - far / 2; a <= mx + far / 2; ++a) {
                for (int b = my - far / 2; b <= my + far / 2; ++b) {
                    if (ch[a][b] == '*') {
                        flag = true;
                        break;
                    }
                }
                if (flag) {
                    break;
                }
            }
            if (flag) {
                continue;
            }

            //能走到这说明这个位置可以移动过来
            vis[mx][my] = true;
            if (mx == n - 3 && my == n - 3) {
                cout << now.t + 1 << endl;
                return;
            }
            q.push({mx, my, now.t + 1});
        }
        q.pop();
    }
}

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> ch[i];
    }
    bfs();
    return 0;
}